package com.eu.ebpm.engine.query;

import com.eu.ebpm.engine.cmd.TaskListCommand;
import com.eu.ebpm.engine.service.Task;

/**
 * 运行任务查询实现
 * @author 王晓华
 *
 */
public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements TaskQuery {

	public TaskQueryImpl() {
		setExecuteCommand(TaskListCommand.class);
	}
	
	public TaskQuery queryById(long id) {
		arg.add(TASK_ID, id);
		return this;
	}

	public TaskQuery queryByAssignee(String assignee) {
		arg.add(TASK_ASSIGNEE, assignee);
		return this;
	}

	public TaskQuery queryByRoler(String roler) {
		arg.add(TASK_ROLER, roler);
		return this;
	}

	public TaskQuery queryByUser(String user) {
		arg.add(TASK_USER, user);
		return this;
	}

	public TaskQuery queryByOrg(String org) {
		arg.add(TASK_ORG, org);
		return this;
	}

	public TaskQuery queryByCandidate(String user, String roler, String org) {
		arg.add(TASK_ORG, org);
		arg.add(TASK_USER, user);
		arg.add(TASK_ROLER, roler);
		return this;
	}

	public TaskQuery orderById() {
		setOrder(COLUMN_ID, "ASC");
		return this;
	}

	public TaskQuery orderByName() {
		setOrder(COLUMN_NAME, "ASC");
		return this;
	}

	public TaskQuery orderByCreatetime() {
		setOrder(COLUMN_CREATETIME, "ASC");
		return this;
	}

	public TaskQuery orderBySigntime() {
		setOrder(COLUMN_ASSIGNEETIME, "ASC");
		return  this;
	}

}
